home *** CD-ROM | disk | FTP | other *** search
Text File | 2003-07-17 | 49.0 KB | 1,910 lines |
- // Copyright (C) 1997-2002 Alias|Wavefront,
- // a division of Silicon Graphics Limited.
- //
- // The information in this file is provided for the exclusive use of the
- // licensees of Alias|Wavefront. Such users have the right to use, modify,
- // and incorporate this code into other products for purposes authorized
- // by the Alias|Wavefront license agreement, without fee.
- //
- // ALIAS|WAVEFRONT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- // INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- // EVENT SHALL ALIAS|WAVEFRONT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
- // CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- // DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
- // TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- // PERFORMANCE OF THIS SOFTWARE.
- //
- //
- // Alias|Wavefront Script File
- // MODIFY THIS AT YOUR OWN RISK
- //
- // ==================== expressionEdCallbacks.mel ==========
- //
- // SYNOPSIS
- //
- // CONTENTS
- // (The procs are in the file in the order listed here.)
- //
- // Expression Editor Procedures:
- //
- //
- // Expression Editor UI control callbacks:
- //
- // EEapplyCB Create/Edit the expression.
- // EEdeleteCB Delete the expression.
- // EErestoreCB Restore the expression.
- // EEclearCB Clear the text area.
- // EEcloseCB Close the window.
- // EEanimatedCB Callback for animated checkbox.
- // EEunitConversionCB Callback for unit conversion radio group.
- // EEexprNameTextCB Callback for expression name textfield.
- // EEdefaultNodeCB Callback for default node name textfield.
- // EEselectedNodeAttrCB Callback for node-attribute name textfield.
- // EEnewExpressionCB Callback for "New Expression" Button.
- // EEnodeListCB User selected something (sngl click) in node list.
- // EEnodeListDblClickCB User selected something (dbl click) in node list
- // EEattrListCB User selected something (sngl click)in attr list.
- // EEattrListDblClickCB User selected something (dbl click) in attr list.
- // EEselectFilterCB User selected something in the Select menu.
- // EEobjFilterCB User selected something in the Obj Filter menu.
- // EEattrFilterCB User selected something in the Attr Filter menu.
- // EEeditorCB User selected something in editors opt menu.
- // EErulesCB User selected a rules radio button.
- // EEmathFuncCB() User selected a math function menu.
- // EEvectFuncCB() User selected a vector function menu.
- // EEconvFuncCB() User selected a conversion function menu.
- // EEarrayFuncCB() User selected a array function menu.
- // EErandFuncCB() User selected a random number function menu.
- //
- // Expression Editor Message Callbacks
- // These are called from TexprEdListenAction.cc
- //
- // EEactiveListChanged Callback for active list changed.
- // EEnodeAdded Callback for a node added to a scene.
- // EEnodeRemoved Callback for a node removed from the scene.
- // EEnodeNameChanged Callback for a node name change in the scene.
- // EEattributeAdded Callback for attribute added to selected node.
- // EEattributeRemoved Callback for attribute removed from selected node.
- // EEexpressionCreated Callback for expression created.
- // EEexpressionEdited Callback for expression edited.
- // EEparticleExpressionCreated Callback for particle expression created.
- // EEparticleExpressionDeleted Callback for particle expression deleted.
- // EEparticleExpressionEdited Callback for particle expression edited.
- // EEclearExpresionEditor Callback for file new/open to clear editor.
- // EEresetExpressionEditor Callback for file open to rebuild the editor.
-
-
- // ******************************************************************
- //
- // EXPRESSION EDITOR CALLBACKS
- //
- //
- // ================ EEapplyCB ================
- //
- // SYNOPSIS
- // Create the expression in the editor and connect it to
- // to the current selected attribute or
- // replace its current expression with the newly edited one.
- //
- //
- global proc EEapplyCB()
- {
- global int $EEobjIsParticle;
- global int $EEcreateMode;
- global string $EEnodeMode;
-
- string $theText;
-
- // Get the value of the text and create or edit the expression node
- //
- $theText = `scrollField -q -tx EEmultiText`;
-
- if (size($theText) == 0 && $EEcreateMode)
- {
- warning "Expression Editor: There's no expression to create.";
- return;
- }
-
- if (size($theText) > 0)
- {
- int $lastIndex = size($theText);
- string $firstChar = substring($theText, 1, 1);
- string $lastChar = substring($theText, $lastIndex, $lastIndex);
-
- // Strip the final carriage returns and spaces.
- //
- while ($lastChar == "\n" || $lastChar == " ")
- {
- if ($lastIndex == 1)
- {
- $theText = "";
- break;
- }
- else
- {
- $theText = substring($theText, 1, size($theText) - 1);
- $lastIndex = $lastIndex - 1;
- $lastChar = substring($theText, $lastIndex, $lastIndex);
- }
- }
-
- if (size($theText) == 0 && $EEcreateMode)
- {
- warning "Expression Editor: There's no expression to create.";
- return;
- }
-
- // If there are quotes surrounding the expression, strip
- // them
- //
- if ($firstChar == "\"")
- {
- $theText = substring ($theText, 2, size($theText));
- }
- if ($lastChar == "\"")
- {
- $theText = substring ($theText, 1, size($theText) - 1);
- }
- }
-
-
- if ($EEobjIsParticle)
- {
- if ($EEcreateMode)
- {
- EEapplyParticleExpression($theText);
- }
- else
- {
- string $objAttrName = `textFieldGrp -q -tx EEselNameT`;
- string $buffer[];
- tokenize($objAttrName, ".", $buffer);
- // If there's no attribute selected, we are definitely
- // doing a dynExprression. If there is one selected,
- // we have to find out what kind of expression it is
- // connected to.
- //
- int $isDynExpression = 1;
- if (size($buffer[1]))
- $isDynExpression = EEisDynExpression($objAttrName);
-
- if ($isDynExpression)
- EEapplyParticleExpression($theText);
- else
- EEapplyExpression($theText);
- }
- }
- else
- {
- if ($EEnodeMode == "scriptNode")
- {
- EEapplyScript($theText);
- }
- else
- {
- EEapplyExpression($theText);
- }
- }
-
- } // EEapplyCB
-
-
-
- // ================ EErestoreCB ================
- //
- // SYNOPSIS
- // Restore the expression in the expression node to the
- // editor text area.
- //
- //
- global proc EErestoreCB()
- {
- global int $EEobjIsParticle;
- global string $EEnodeMode;
-
- string $currObjAttrName;
-
- if ($EEnodeMode == "expression")
- {
- EErestoreExpression();
- }
- else if ($EEnodeMode == "scriptNode")
- {
- EErestoreScript();
- }
- else
- {
- if ($EEobjIsParticle)
- {
- EErestoreParticleExpression();
- }
- else
- {
- EErestoreExpression();
- }
- }
-
- } // EErestoreCB
-
-
- // ================ EEclearCB ================
- //
- // SYNOPSIS
- // Clear the text.
- //
- //
- global proc EEclearCB()
- {
- scrollField -e -tx "" EEmultiText;
-
- } // EEclearCB
-
-
- // ================ EEcloseCB =================
- //
- // SYNOPSIS
- // Close the expression editor window
- //
- //
- global proc EEcloseCB()
- {
- deleteUI expressionEditorWin;
-
- } // EEcloseCB
-
-
- // ================ EEanimatedCB ================
- //
- // SYNOPSIS
- // Called when the animated checkbox is changed.
- //
- global proc EEanimatedCB()
- {
- global int $EEcreateMode;
- global int $EEeditedInEditor;
- global string $EEcurrExpressionName;
-
- // If in edit mode, reset the expression animated value immediately.
- //
- if (!$EEcreateMode)
- {
- int $anFlagVal = `checkBox -q -v EEanimCBox`;
- $EEeditedInEditor = 1;
- evalEcho("expression -e -ae "+$anFlagVal+" "+$EEcurrExpressionName);
- }
-
- } // EEanimatedCB
-
-
- // ================ EEunitConversionCB ================
- //
- // SYNOPSIS
- // Called when the unit conversion radio set is changed.
- //
- global proc EEunitConversionCB(string $thePref)
- {
- global int $EEcreateMode;
- global int $EEobjIsParticle;
- global int $EEeditedInEditor;
- global string $EEcurrExpressionName;
-
- // If in edit mode, reset the expression unit conversion preference
- // immediately.
- //
- if (!$EEcreateMode)
- {
- if (!$EEobjIsParticle)
- {
- $EEeditedInEditor = 1;
- evalEcho("expression -e -uc "+$thePref+" "+$EEcurrExpressionName);
- }
- }
-
- } // EEunitConversionCB
-
-
- // ================ EEexprNameTextCB ================
- //
- // SYNOPSIS
- // Called when the expression name textfield is changed.
- //
- global proc EEexprNameTextCB()
- {
- global string $EEcurrExpressionName;
- global string $EEcurrFileExprName[];
- global int $EEexpressionInEditor;
- global int $EEcreateMode;
- global int $EEcurrentEditor;
- global int $EEeditedInEditor;
- global string $EEnodeMode;
-
- string $exprName = `textField -q -tx EEexprNameT`;
-
- // If $exprName == "" and in edit mode, then return text field
- // to what it was
- //
- if( $exprName == "" && !$EEcreateMode)
- {
- if (size($EEcurrExpressionName) > 0)
- {
- textField -e -tx $EEcurrExpressionName EEexprNameT;
- }
- else
- {
- textField -e -tx "" EEexprNameT;
- }
- return;
- }
-
- // If $exprName == $currExpressionName, it means either
- // that the new name has already been processed, or the
- // field was touched but nothing changed. So just return.
- // (The former can happen if the user does not press carriage
- // return, and then selects "Apply", because there is
- // no focus-out callback available in ELF.)
- //
- if ($exprName == $EEcurrExpressionName)
- return;
-
- // If the name the user typed is already the name of an
- // expression node then it is not valid; the EEcheckValidExprName
- // proc will remove it and restore the previous name, and return
- // 0.
- //
- int $nameValid;
- if ($EEnodeMode == "scriptNode")
- {
- if ($nameValid = EEcheckValidScriptName($exprName))
- {
- if (!$EEcreateMode)
- {
- // If in edit mode, rename the script
- //
- $EEeditedInEditor = 1;
- $exprName =
- evalEcho("rename "+$EEcurrExpressionName+" "+$exprName);
-
- textFieldGrp -e -tx $exprName EEselScriptNodeNameT;
-
- // If the user is in a text editor mode, have to update to
- // the new expression name in the file array.
- //
- if ($EEexpressionInEditor > -1 && $EEcurrentEditor != 1)
- {
- if ($EEcurrFileExprName[$EEexpressionInEditor] == $EEcurrExpressionName)
- $EEcurrFileExprName[$EEexpressionInEditor] = $exprName;
- }
-
- $EEcurrExpressionName = $exprName;
- textField -e -tx $EEcurrExpressionName EEexprNameT;
-
- if (EEscriptNameExists($exprName))
- EEupdateExprList();
- }
- }
- }
- else
- {
- if ($nameValid = EEcheckValidExprName($exprName))
- {
- // If in edit mode, rename the expression immediately.
- if (!$EEcreateMode)
- {
- $EEeditedInEditor = 1;
- $exprName = evalEcho("expression -e -n \""+$exprName+"\" "+$EEcurrExpressionName+"\n");
-
- // If the user is in a text editor mode, have to update to
- // the new expression name in the file array, if this is
- // not a particle expression.
- //
- if ($EEexpressionInEditor > -1 && $EEcurrentEditor != 1)
- {
- if ($EEcurrFileExprName[$EEexpressionInEditor] == $EEcurrExpressionName)
- $EEcurrFileExprName[$EEexpressionInEditor] = $exprName;
- }
- }
- $EEcurrExpressionName = $exprName;
- textField -e -tx $EEcurrExpressionName EEexprNameT;
-
- // If the user is in select-by-expression mode, update the
- // list of expressions with the new name, if the new name
- // is an existing expression. Otherwise the user is creating
- // a name for a new expression.
- //
- if (EEexprNameExists($exprName))
- EEupdateExprList();
- }
- }
-
- } // EEexprNameTextCB
-
- // ================ EEdefaultNodeCB ================
- //
- // SYNOPSIS
- // Called when the Default Object name textfield is changed.
- //
- global proc EEdefaultNodeCB()
- {
- global int $EEcreateMode;
- global int $EEeditedInEditor;
- global string $EEcurrExpressionName;
-
- string $newObjName;
-
- // Get the newly typed Object name
- //
- $newObjName = `textFieldGrp -q -tx EEdefNameT`;
-
- if (size($newObjName) == 0)
- {
- textFieldGrp -e -tx "" EEdefNameT;
- return;
- }
- if (!EEisValidNodeName($newObjName))
- {
- textFieldGrp -e -tx "" EEdefNameT;
- return;
- }
- if (!$EEcreateMode)
- {
- $EEeditedInEditor = 1;
- evalEcho("expression -e -o "+$newObjName+" "+$EEcurrExpressionName+"\n");
- }
-
- } // EEdefaultNodeCB
-
-
- // ================ EEselectedNodeAttrCB ================
- //
- // SYNOPSIS
- // Called when the selected object.attribute name textfield
- // is changed.
- //
- global proc EEselectedNodeAttrCB()
- {
- string $currentAttrs[];
- string $nodeNames[], $names[];
- int $attrListIndex;
-
- string $objAttrName = `textFieldGrp -q -tx EEselNameT`;
- string $buffer[];
- tokenize($objAttrName, ".", $buffer);
- string $nodeName = $buffer[0];
- string $attrName = $buffer[1];
-
- if (size($nodeName) == 0 && size($attrName) == 0)
- {
- // The textfield is empty, so deselect everything
- // and clear controls.
- //
- EEclearAllControls();
-
- textScrollList -e -da EEnodeList;
- textScrollList -e -da EEattrList;
-
- return;
- }
-
- if (size($attrName) == 0 )
- {
- // There's only one name in the textfield: start out by
- // assuming it's an attribute name.
- //
- $attrName = $nodeName;
-
- // If the name is in the attribute list for the currently
- // selected object, load it.
- //
- if ((($attrListIndex = EEattrIsInList($attrName)) > -1) ||
- (($attrListIndex = EEgetAttrFromNode($attrName)) > -1))
- {
- EEnewSelectedAttr($attrListIndex);
-
- // Get the name of the current object and long name of the
- // newly typed attribute for future reference.
- //
- $names = `textScrollList -q -si EEnodeList`;
- $nodeName = $names[0];
- $names = `textScrollList -q -si EEattrList`;
- $attrName = $names[0];
-
- }
- else
- {
- // The name is not in the attribute list, so it must
- // be an object name. Deselect the selected attribute
- // in the attribute list; clear the controls (the obj
- // name will be re-instated later); if the name is in
- // the object list, make it selected, and build its
- // attribute list.
- //
- textScrollList -e -da EEattrList;
- EEclearAllControls();
-
- if (EEnodeIsInList($nodeName) > -1)
- {
- EEnewSelectedNode($nodeName);
- $attrName = "";
- }
- else
- {
- // Name is not in object list. Check if it's a valid
- // object in the scene and if it is:
- // Reset the filter to all dag objs or dep nodes, rebuild
- // the object list, make the new object selected, and
- // build its attribute list.
- //
- if (EEisValidNodeName($nodeName))
- {
- EEresetFilterToAll($nodeName);
- EEnewSelectedNode($nodeName);
- $attrName = "";
- }
- else
- {
- // Reset the textfield with the current obj/attr name,
- // if there is one .
- //
- string $names[];
- $names = `textScrollList -q -si EEnodeList`;
- $nodeName = $names[0];
- $names = `textScrollList -q -si EEattrList`;
- $attrName = $names[0];
- }
- }
- }
- }
- else
- {
- // User typed object.attribute
-
- // Is the object currently selected in the object list?
- //
- $nodeNames = `textScrollList -q -si EEnodeList`;
- if ($nodeName == $nodeNames[0])
- {
- // Make the newly typed attribute selected, if it's really
- // an attribute of the currently selected object.
- //
- if ((($attrListIndex = EEattrIsInList($attrName)) > -1) ||
- (($attrListIndex = EEgetAttrFromNode($attrName)) > -1))
- {
- EEnewSelectedAttr($attrListIndex);
- $names = `textScrollList -q -si EEattrList`;
- $attrName = $names[0];
- }
- else
- {
- warning ("Expression Editor: name "+$attrName+" is not an attribute of object "+$nodeName+".");
- }
- }
- else if (EEnodeIsInList($nodeName) > -1)
- {
- // User typed an object, and it is in the object list. So
- // make it selected, and build its attribute list. Then
- // make the newly typed attribute selected, if it's a
- // valid attribute name.
- //
- EEnewSelectedNode($nodeName);
-
- if ((($attrListIndex = EEattrIsInList($attrName)) > -1) ||
- (($attrListIndex = EEgetAttrFromNode($attrName)) > -1))
- {
- EEnewSelectedAttr($attrListIndex);
- $names = `textScrollList -q -si EEattrList`;
- $attrName = $names[0];
- }
- else
- {
- warning ("Expression Editor: name "+$attrName+" is not an attribute of object "+$nodeName+".");
- }
- }
- else
- {
- // User typed an object name that's not in the object list.
- // If it's a valid object, reset filter to all dag objs or
- // dep nodes (for consistency in lists), rebuild the object
- // list, make the new object selected, and build its
- // attribute list.
- //
- if (EEisValidNodeName($nodeName))
- {
- EEresetFilterToAll($nodeName);
- EEnewSelectedNode($nodeName);
- if (($attrListIndex = EEattrIsInList($attrName)) > -1)
- {
- EEnewSelectedAttr($attrListIndex);
- $names = `textScrollList -q -si EEattrList`;
- $attrName = $names[0];
- }
- else
- {
- warning ("Expression Editor: "+$attrName+" is not an attribute of "+$nodeName+".");
- }
- }
- }
- }
-
- // Re-write the textfield to make sure the long attribute name is
- // in it.
- //
- if (size($attrName) > 0)
- {
- string $newString = $nodeName+"."+$attrName;
- textFieldGrp -e -tx $newString EEselNameT;
- }
-
- clear($buffer);
- clear($currentAttrs);
- clear($nodeNames);
-
- } // EEselectedNodeAttrCB
-
-
-
- // ================ EEnewExpressionCB ================
- //
- // SYNOPSIS
- // Called when the "New Expression" button is selected.
- //
- global proc EEnewExpressionCB(int $launchEditor)
- {
- global string $EEnodeMode;
- global int $EEobjIsParticle;
- global int $EEcurrentEditor;
- global int $EEdoLaunchTextEd;
-
- string $currObjAttr;
- string $buffer[];
-
- if ( $EEobjIsParticle)
- $currObjAttr = `textFieldGrp -q -tx EEselNameT`;
- else
- $currObjAttr = `textFieldGrp -q -tx EEdefNameT`;
-
- tokenize($currObjAttr, ".", $buffer);
-
- if ($EEnodeMode == "object")
- {
- // If in object mode and the current selected attribute already
- // is connected to an expression, then the new expression will
- // be unrelated to it, so deselect it.
- //
- string $expression = `scrollField -q -text EEmultiText`;
- if (size($expression) > 0)
- textScrollList -e -da EEattrList;
- }
- else
- {
- textScrollList -e -da EEnodeList;
- }
-
- if ($EEcurrentEditor != 1 && $launchEditor)
- $EEdoLaunchTextEd = 1;
-
- EEdisplayNoExpression($buffer[0]);
-
- } // EEnewExpressionCB
-
-
- // ================ EEdeleteCB ================
- //
- // SYNOPSIS
- // Delete the expression in the editor.
- //
- //
- global proc EEdeleteCB()
- {
- global int $EEobjIsParticle;
- global int $EEisRuntime;
- global string $EEnodeMode;
- global int $EEcreateMode;
-
- if ($EEcreateMode)
- {
- warning "Expression Editor: In create mode; there's nothing to delete.";
- return;
- }
-
- // Delete the expression.
- //
- if ($EEobjIsParticle)
- {
- // To delete a particle expression, just blank it out.
- //
- string $objAttrName = `textFieldGrp -q -tx EEselNameT`;
- string $buffer[];
- tokenize($objAttrName, ".", $buffer);
- string $nodeName = $buffer[0];
- string $attrName = $buffer[1];
-
- EEdynExpressionCmd($EEisRuntime, "", $nodeName);
- }
- else
- {
- // Get the expression name, and call delete on it.
- //
- string $exprName = `textField -q -tx EEexprNameT`;
- evalEcho("delete "+$exprName);
- }
-
- // Re-set to new expression mode
- //
- EEnewExpressionCB(0);
-
- } // EEdeleteCB
-
- // ================ EEnodeListCB ================
- //
- // SYNOPSIS
- // Something in the scrolled text list of nodes is selected.
- //
- global proc EEnodeListCB()
- {
- global string $EEcurrSelectedNode;
- global string $EEnodeMode;
- global int $EEobjIsParticle;
- global int $EEdoLaunchTextEd;
- global int $EEpExpressionInEditor;
- global int $EEexpressionInEditor;
-
- string $nodeName[];
-
- $nodeName = `textScrollList -q -si EEnodeList`;
-
- // Here and below have to take into account that the user may
- // have clicked (esp. double-clicked) on the node that is
- // currently already in the editor. In that case, the only
- // thing that needs to be done is launch a text editor, if the
- // the user double-clicked.
- //
- if ($nodeName[0] != $EEcurrSelectedNode)
- {
- // Stop the attribute changed message for the previous selection.
- //
- if (size($EEcurrSelectedNode) > 0)
- expressionEditorListen -sla $EEcurrSelectedNode;
-
- // Whatever text editor file may have been for the current
- // expression, it isn't now, because a new node was selected.
- //
- $EEpExpressionInEditor = -1;
- $EEexpressionInEditor = -1;
-
- // Start the attribute changed message for the new selection
- //
- expressionEditorListen -la $nodeName[0];
- }
-
- if (EEisParticle($nodeName[0]))
- {
- $EEobjIsParticle = 1;
- EEparticleListChanged($nodeName[0]);
- }
- else
- {
- $EEobjIsParticle = 0;
- if ($EEnodeMode == "object")
- EEobjectListChanged($nodeName[0]);
- else if ($EEnodeMode == "scriptNode")
- {
- attrEnumOptionMenu -e
- -at ($nodeName[0] + ".scriptType") EEscriptNodeTypeAOM;
-
- EEscriptListChanged($nodeName[0]);
- }
- else
- EEexpressionListChanged($nodeName[0]);
- }
-
- $EEcurrSelectedNode = $nodeName[0];
- $EEdoLaunchTextEd = 0;
-
- clear ($nodeName);
-
- } // EEnodeListCB
-
-
- // ================ EEnodeListDblClickCB ================
- //
- // SYNOPSIS
- // Something in the scrolled text list of nodes is selected with
- // double click
- //
- global proc EEnodeListDblClickCB()
- {
- global int $EEdoLaunchTextEd;
-
- $EEdoLaunchTextEd = 1;
-
- EEnodeListCB();
-
- } // EEnodeListDblClickCB
-
-
- // ================ EEattrListCB ================
- //
- // SYNOPSIS
- // Something in the scrolled text list of attributes is selected.
- //
- global proc EEattrListCB()
- {
- global int $EEobjIsParticle;
- global int $EEcurrentEditor;
- global int $EEdoLaunchTextEd;
-
- string $nodeName[], $attrName[];
-
- // Get the newly selected attribute name, and the current object
- // name in the list, and load them.
- //
- $attrName = `textScrollList -q -si EEattrList`;
- $nodeName = `textScrollList -q -si EEnodeList`;
-
- EEloadNewNodeAttr($nodeName[0], $attrName[0]);
-
- } // EEattrListCB
-
-
- // ================ EEattrListDblClickCB ================
- //
- // SYNOPSIS
- // Something in the scrolled text list of attributes is selected
- // with double click.
- //
- global proc EEattrListDblClickCB()
- {
- global int $EEdoLaunchTextEd;
- string $nodeName[], $attrName[];
-
- $EEdoLaunchTextEd = 1;
-
- EEattrListCB();
-
- } // EEattrListDblClickCB
-
-
- // ================ EEselectFilterCB ================
- //
- // SYNOPSIS
- // Called when the "Select Filter" menu is changed.
- //
- global proc EEselectFilterCB(string $whichMethod)
- {
- // Set up the requested layout.
- //
- EEswitchSelectLayout($whichMethod);
-
- EErebuildNodeList($whichMethod);
-
- if ($whichMethod == "object")
- button -e -enable false EEnewExpButton;
- else
- button -e -enable true EEnewExpButton;
-
- } // EEselectFilterCB
-
-
- // ================ EEobjFilterCB ================
- //
- // SYNOPSIS
- // Called when the Object Filter menu is changed.
- //
- global proc EEobjFilterCB(string $whichFilter)
- {
- global string $EEnodeMode;
- global string $EEcurrNodeFilter;
-
- $EEcurrNodeFilter = $whichFilter;
-
- if ($EEnodeMode == "object")
- EErebuildNodeList($EEnodeMode);
-
- } // EEobjFilterCB
-
-
- // ================ EEattrFilterCB ================
- //
- // SYNOPSIS
- // Called when the Attribute Filter menu is changed.
- //
- global proc EEattrFilterCB(string $whichFilter)
- {
- global string $EEnodeMode;
- global string $EEcurrAttrFilter;
-
- $EEcurrAttrFilter = $whichFilter;
-
- if ($EEnodeMode == "object")
- {
- // Rebuild the attribute list if there is a selected
- // object in the object list. If there was a selected
- // attribute in the list and it is still in the list,
- // make it selected again.
- //
- string $selAttr[] = `textScrollList -q -si EEattrList`;
- string $selObj[] = `textScrollList -q -si EEnodeList`;
-
- if (size($selObj[0]) > 0)
- EErebuildAttrList($selObj[0]);
-
- if (size($selAttr[0]) > 0)
- {
- if (EEattrIsInList($selAttr[0]) > -1)
- textScrollList -e -si $selAttr[0] EEattrList;
- }
- }
-
- } // EEattrFilterCB
-
-
- // ================ EEeditorCB ================
- //
- // SYNOPSIS
- // Called when the Editor Type option menu is changed.
- //
- global proc EEeditorCB()
- {
- global int $EEcurrentEditor;
- global int $EEobjIsParticle;
-
- string $buffer[];
- string $winEditor;
- string $theEditor, $theMessage;
-
- int $EEcurrentEditor = `optionMenu -q -sl EEeditorOM`;
-
- if (`about -irix`)
- {
- switch($EEcurrentEditor)
- {
- case 1: $theEditor = "Expression";
- break;
- case 2: $theEditor = "jot";
- break;
- case 3: $theEditor = "vi";
- break;
- case 4: $theEditor = "vim";
- break;
- case 5: $theEditor = "xemacs";
- break;
- case 6: $theMessage = EEgetEditorMessage();
- $winEditor = getenv("WINEDITOR");
- if (size($winEditor) == 0)
- $theMessage =
- $theMessage + "Currently \"WINEDITOR\" is not set.";
- else
- $theMessage =
- $theMessage + "\"WINEDITOR\" is now set to \"" + $winEditor + "\".";
- EEpostConfirm($theMessage);
- if (size($winEditor) > 0)
- {
- tokenize($winEditor, " ", $buffer);
- $theEditor = $buffer[0];
- }
- else
- {
- warning ("Expression Editor: To use \"Other\" editor, set \"WINEDITOR\"");
- optionMenu -e -sl 1 EEeditorOM;
- scrollField -e -enable true EEmultiText;
- return;
- }
- break;
- }
- }
- if (`about -linux`)
- {
- switch($EEcurrentEditor)
- {
- case 1: $theEditor = "Expression";
- break;
- case 2: $theEditor = "emacs";
- break;
- case 3: $theEditor = "gvim";
- break;
- case 4: $theEditor = "vi";
- break;
- case 5: $theEditor = "vim";
- break;
- case 6: $theEditor = "xedit";
- break;
- case 7: $theEditor = "xemacs";
- break;
- case 8: $theMessage = EEgetEditorMessage();
- $winEditor = getenv("WINEDITOR");
- if (size($winEditor) == 0)
- $theMessage =
- $theMessage + "Currently \"WINEDITOR\" is not set.";
- else
- $theMessage =
- $theMessage + "\"WINEDITOR\" is now set to \"" + $winEditor + "\".";
- EEpostConfirm($theMessage);
- if (size($winEditor) > 0)
- {
- tokenize($winEditor, " ", $buffer);
- $theEditor = $buffer[0];
- }
- else
- {
- warning ("Expression Editor: To use \"Other\" editor, set \"WINEDITOR\"");
- optionMenu -e -sl 1 EEeditorOM;
- scrollField -e -enable true EEmultiText;
- return;
- }
- break;
- }
- }
-
- // First test that the editor exists in the user's path. If
- // it doesn't, send a message and revert to the Expression
- // Editor.
- //
- if ($EEcurrentEditor == 1)
- {
- // User is switching back to edit in the Expression Editor:
- // Check that the current expression is not already in a
- // text editor. If it is, don't switch, and warn the user
- // to dismiss the text editor first.
- //
- string $expressionName = `textField -q -text EEexprNameT`;
- int $index = -1;
- if (size($expressionName))
- {
- if ($EEobjIsParticle)
- {
- if (size($expressionName))
- $index = EEexpressionIsInTextEditor($expressionName, 1);
- }
- else
- {
- if (size($expressionName))
- $index = EEexpressionIsInTextEditor($expressionName, 0);
- }
- if ($index > -1)
- {
- // The current expression is in a text editor.
- //
- warning("The current expression is in a text editor.");
-
- }
- }
- if ($index > -1)
- scrollField -e -enable false EEmultiText;
- else
- scrollField -e -enable true EEmultiText;
- }
-
- } // EEeditorCB
-
-
- // ================ EErulesCB ================
- //
- // SYNOPSIS
- // Called when the rules radio button is changed.
- //
- global proc EErulesCB(string $whichRule)
- {
- global int $EEisRuntime;
- string $EEnodeMode;
- string $particleExpr;
-
- string $objAttrName = `textFieldGrp -q -tx EEselNameT`;
- string $buffer[];
- tokenize($objAttrName, ".", $buffer);
-
- int $whichButton = `radioButtonGrp -q -sl EErulesRBG`;
-
- if ($whichButton == 1)
- $EEisRuntime = 1;
- else
- $EEisRuntime = 0;
-
- $particleExpr = EEgetParticleExpression($buffer[0], "");
-
- if (size($particleExpr) > 0)
- {
- scrollField -e -tx $particleExpr EEmultiText;
- EEsetEditMode("Editing ParticleExpression");
- }
- else
- {
- scrollField -e -tx "" EEmultiText;
- EEsetCreateMode("Creating Particle Expression");
- }
-
- // Putting a new expression in the editor, so enable multiText
- // if the expression is not already in a file.
- //
- int $index = EEexpressionIsInTextEditor($buffer[0], 1);
- if ($index == -1)
- scrollField -e -enable true EEmultiText;
- else
- scrollField -e -enable false EEmultiText;
-
- } // EErulesCB
-
- // ================ EEmathFuncCB ================
- //
- // SYNOPSIS
- // Called when the math function is selected
- //
- global proc EEmathFuncCB(int $index)
- {
- global string $EEMathFunction[];
-
- scrollField -e -it $EEMathFunction[$index] EEmultiText;
- textField -e -tx $EEMathFunction[$index+1] EEhelpField;
-
- } // EEmathFuncCB
-
- // ================ EEvectFuncCB ================
- //
- // SYNOPSIS
- // Called when the vector function is selected
- //
- global proc EEvectFuncCB(int $index)
- {
- global string $EEVectorFunction[];
-
- scrollField -e -it $EEVectorFunction[$index] EEmultiText;
- textField -e -tx $EEVectorFunction[$index+1] EEhelpField;
-
- } // EEvectFuncCB
-
- // ================ EEconvFuncCB ================
- //
- // SYNOPSIS
- // Called when the conversion function is selected
- //
- global proc EEconvFuncCB(int $index)
- {
- global string $EEConversionFunction[];
-
- scrollField -e -it $EEConversionFunction[$index] EEmultiText;
- textField -e -tx $EEConversionFunction[$index+1] EEhelpField;
-
- } // EEconvFuncCB
-
- // ================ EEarrayFuncCB ================
- //
- // SYNOPSIS
- // Called when the array function is selected
- //
- global proc EEarrayFuncCB(int $index)
- {
- global string $EEArrayFunction[];
-
- scrollField -e -it $EEArrayFunction[$index] EEmultiText;
- textField -e -tx $EEArrayFunction[$index+1] EEhelpField;
-
- } // EEarrayFuncCB
-
- // ================ EErandFuncCB ================
- //
- // SYNOPSIS
- // Called when the random function is selected
- //
- global proc EErandFuncCB(int $index)
- {
- global string $EERandomFunction[];
-
- scrollField -e -it $EERandomFunction[$index] EEmultiText;
- textField -e -tx $EERandomFunction[$index+1] EEhelpField;
-
- } // EErandFuncCB
-
- // ================ EEcurveFuncCB ================
- //
- // SYNOPSIS
- // Called when the curve function is selected
- // This block has distinct elements for the menu label
- // (the first string in each set)
- // and the literal string to insert in the expression (the second)
- // in order to distinguish between the 2 overloaded
- // versions of hermite().
- //
- global proc EEcurveFuncCB(int $index)
- {
- global string $EECurveFunction[];
-
- scrollField -e -it $EECurveFunction[$index+1] EEmultiText;
- textField -e -tx $EECurveFunction[$index+2] EEhelpField;
-
- } // EEcurveFuncCB
-
-
- // ******************************************************************
- //
- // EXPRESSION EDITOR MESSAGE CALLBACKS
- //
- // These procs are called from TexprEdListenAction.cc, when
- // messages are received that there are active list or database
- // changes
- //
- // ================ EEactiveListChanged ================
- //
- // SYNOPSIS
- // The active (selection) list has changed. So update the
- // object list.
- //
- //
- global proc EEactiveListChanged()
- {
- global string $EEnodeMode;
- global string $EEcurrNodeFilter;
-
- // If the current filter is "allSelected", rebuild the
- // list. (If not "allSelected", no need to change. Messages that
- // objects have been added/removed are handled elsewhere.
- //
- if (`window -exists "expressionEditorWin"`)
- {
- if ($EEnodeMode == "object" && $EEcurrNodeFilter == "allSelected")
- {
- EErebuildNodeList($EEnodeMode);
- }
- }
- } // EEactiveListChanged
-
-
- // ================ EEnodeAdded ================
- //
- // SYNOPSIS
- // A node has been added to the scene. Update the
- // object/attribute list, if needed.
- //
- //
- global proc EEnodeAdded(string $nodeName)
- {
- global string $EEnodeMode;
- global string $EEcurrNodeFilter;
-
- if (!`window -exists "expressionEditorWin"`)
- {
- return;
- }
-
- string $nodeList[];
- int $i;
-
- // If the new node is a particle or expression, we have to register
- // to listen for creation/deletion of expressions.
- //
- if (EEisParticle($nodeName) || EEisExpression($nodeName))
- expressionEditorListen -le $nodeName;
-
- // If in expression mode, get the name of all expressions.
- // If in object mode, get the name of all objects of the type
- // that is currently being displayed. If the new node is in
- // the list, add it to the text scroll list.
- //
- if ($EEnodeMode == "expression")
- {
- $nodeList = EEgetExpressionList();
- }
- else if ($EEnodeMode == "scriptNode")
- {
- $nodeList = EEgetCurrTypeList("scriptNode");
- }
- else
- {
- $nodeList = EEgetCurrTypeList($EEcurrNodeFilter);
- }
-
- for ($i = 0; $i < size($nodeList); $i++)
- {
- if ($nodeName == $nodeList[$i])
- {
- EEaddNodeToList($nodeName);
- break;
- }
- }
-
- // If in object mode and a new expression node has been created,
- // and it has been connected to the currently selected object.attr,
- // then load it into the editor.
- //
- if ($EEnodeMode == "object" && EEisExpression($nodeName))
- {
- // Get the selected obj.attr. If there is one, and it is
- // connected to nodeName, then display the expression
- //
- string $selectedNode[] = `textScrollList -q -si EEnodeList`;
- string $selectedAttr[] = `textScrollList -q -si EEattrList`;
- if (size($selectedNode) && size($selectedAttr))
- {
- string $objAttr = $selectedNode[0] +"."+$selectedAttr[0];
-
- string $exprName[] =
- `listConnections -s true -d false -t "expression" -scn true $objAttr`;
-
- // If the obj.attr is connected to the expression node,
- // load it.
- //
- if ($exprName[0] == $nodeName)
- EEdisplayExpression($objAttr);
- }
- }
-
- } // EEnodeAdded
-
-
- // ================ EEnodeRemoved ================
- //
- // SYNOPSIS
- // A node has been removed from the scene. Remove it
- // from the object/attribute list, if needed.
- //
- //
- global proc EEnodeRemoved(string $nodeName)
- {
- global string $EEnodeMode;
- global int $EEobjIsParticle;
-
- if (!`window -exists "expressionEditorWin"`)
- {
- return;
- }
-
- string $objectList[] = `textScrollList -q -ai EEnodeList`;
-
- // If the node is a particle or expression, unregister it to receive
- // expression changed messages.
- //
- if (EEisParticle($nodeName) || EEisExpression($nodeName))
- expressionEditorListen -sle $nodeName;
-
- // If the deleted node is in the list, remove it. If it
- // is the selected node, clear the attribute list, and
- // make nothing selected in the node list.
- //
- int $i;
- int $nodeWasInList = 0;
- for($i = 0; $i < size($objectList); $i++)
- {
- if ($nodeName == $objectList[$i])
- {
- string $selected[] = `textScrollList -q -si EEnodeList`;
- EEremoveNodeFromList($nodeName, 1);
- $nodeWasInList = 1;
- if ($nodeName == $selected[0])
- {
- textScrollList -e -ra EEattrList;
-
- // At this point nothing is selected, so put the editor
- // in create non-particle mode (non-particle so the user
- // can use the "New Expression" button.)
- //
- EEclearAllControls();
- if ($EEobjIsParticle)
- {
- $EEobjIsParticle = 0;
- if ($EEnodeMode == "scriptNode")
- {
- EEsetCreateMode("Creating Script Node");
- }
- else
- {
- EEsetCreateMode("Creating Expression");
- }
- EEswitchRulesForm(0);
- textFieldGrp -e -tx "" -enable true EEdefNameT;
- text -e -enable true EEexprNameLabel;
- }
- }
- break;
- }
- }
- // If the node was not in the node list, it could still, if it
- // was an expression, have been connected to the current obj.attr.
- // So, if in object mode and the node just deleted was an expression,
- // if it is in the editor, remove it.
- //
- // NEW
- if (!$nodeWasInList &&
- EEisExpression($nodeName) &&
- $EEnodeMode == "object")
- {
- string $exprName = `textField -q -tx EEexprNameT`;
- if ($exprName == $nodeName)
- EEdisplayNoExpression($nodeName);
- }
-
- } // EEnodeRemoved
-
-
- // ================ EEnodeNameChanged ================
- //
- // SYNOPSIS
- // The name of a node has been changed, so reflect the change
- // in the list.
- //
- //
- global proc EEnodeNameChanged(string $oldNodeName, string $newNodeName)
- {
- global string $EEnodeMode;
-
- if (!`window -exists "expressionEditorWin"`)
- return;
-
- // Find the old name in the object list, get its index, and find out if it
- // is selected.
- // Remove the old name from the list and add the new name in the same spot
- // If it is selected, select it and change the name in the selected object
- // textfield, and the default textfield if it is there.
- //
- string $nodeList[] = `textScrollList -q -ai EEnodeList`;
- int $selected[] = `textScrollList -q -sii EEnodeList`;
- int $renamedNode;
-
- int $i;
- for ($i = 0; $i < size($nodeList); $i++)
- {
- if ($oldNodeName == $nodeList[$i])
- {
- // Found the old node name in the scrolled list of nodes.
- // So remove it, and replace it with the new name.
- //
- int $index = $i + 1;
- textScrollList -e -rii $index EEnodeList;
- textScrollList -e -ap $index $newNodeName EEnodeList;
- if ($selected[0] == $index)
- {
- // The renamed node is the one selected in the list, so now
- // select the new name, and put it in the Expression Name
- // textfield..
- //
- textScrollList -e -sii $index EEnodeList;
-
- // If in object mode, reset the selected and default textfields
- // if the renamed object is the one selected in the editor.
- //
- if ($EEnodeMode == "object")
- {
- string $objAttrName = `textFieldGrp -q -tx EEselNameT`;
- string $buffer[];
- tokenize($objAttrName, ".", $buffer);
- $objAttrName = $newNodeName;
- if (size($buffer) == 2)
- $objAttrName = $objAttrName + "." + $buffer[1];
- textFieldGrp -e -tx $objAttrName EEselNameT;
- string $defObjName = `textFieldGrp -q -tx EEdefNameT`;
- if (size($defObjName) > 0)
- textFieldGrp -e -tx $newNodeName EEdefNameT;
- }
-
- if ($EEnodeMode == "scriptNode")
- {
- textFieldGrp -e -tx $newNodeName EEselNameT;
- }
- }
- }
- }
-
- // If the new node name is an expression name and is currently
- // in the Expression Name textfield, then put the new name in
- // the field.
- //
- string $currExprName = `textField -q -tx EEexprNameT`;
-
- if ($oldNodeName == $currExprName)
- {
- textField -e -tx $newNodeName EEexprNameT;
- }
-
- } // EEnodeNameChanged
-
-
- // ================ EEattributeAdded ================
- //
- // SYNOPSIS
- // An attribute has been added to a node. So add it to
- // the Attributes list, if this node is selected, and if
- // the attribute meets the requirements.
- //
- //
- global proc EEattributeAdded(string $nodeName, string $attributeName)
- {
- if (!`window -exists "expressionEditorWin"`)
- return;
-
- string $selectedNode[] = `textScrollList -q -si EEnodeList`;
-
- if ($nodeName == $selectedNode[0])
- {
- // If the node is a particle, eliminate a few attributes we
- // don't want in the editor.
- //
- if (EEisParticle($nodeName))
- {
- if (EEisValidDynAttr($attributeName))
- textScrollList -e -a $attributeName EEattrList;
- }
- else
- textScrollList -e -a $attributeName EEattrList;
- }
-
- } // EEattributeAdded
-
-
- // ================ EEattributeRemoved ================
- //
- // SYNOPSIS
- // An attribute has been removed to the node. So remove it
- // from the Attributes list, if this node is selected.
- //
- global proc EEattributeRemoved(string $nodeName, string $attributeName)
- {
-
- if (!`window -exists "expressionEditorWin"`)
- return;
-
- string $selectedNode[] = `textScrollList -q -si EEnodeList`;
- string $selectedAttr[] = `textScrollList -q -si EEattrList`;
-
- if ($nodeName == $selectedNode[0])
- {
- // Remove the attribute from the list, if it is in the list.
- //
- string $listAttrs[] = `textScrollList -q -ai EEattrList`;
- int $i;
- for ($i = 0; $i < size($listAttrs); $i++)
- {
- if ($listAttrs[$i] == $attributeName)
- {
- textScrollList -e -ri $attributeName EEattrList;
- if ($attributeName == $selectedAttr[0])
- {
- // If the removed attribute was the selected one, clear
- // the controls and set the first attribute in the list
- // to be selected.
- //
- EEclearAllControls();
- textScrollList -e -sii 1 EEattrList;
- }
- break;
- }
- }
- }
-
- } // EEattributeRemoved
-
-
- // ================ EEexpressionCreated ================
- //
- // SYNOPSIS
- // An expression has been created from outside the editor.
- // If it's in the editor, reload it.
- //
- //
- global proc EEexpressionCreated(string $expressionName)
- {
- global int $EEeditedInEditor;
- global string $EEnodeMode;
-
- if (!`window -exists "expressionEditorWin"`)
- return;
-
- if ($EEeditedInEditor)
- {
- $EEeditedInEditor = 0;
- return;
- }
-
- // If the obj.attr this expression is connected to is in the
- // editor, load it.
- //
- if ($EEnodeMode == "object")
- {
- string $selectedNode[] = `textScrollList -q -si EEnodeList`;
- string $selectedAttr[] = `textScrollList -q -si EEattrList`;
- if (size($selectedNode) && size($selectedAttr))
- {
- string $selObjAttr = $selectedNode[0] +"."+$selectedAttr[0];
- string $objAttr[] =
- `listConnections -source false -d true -shapes true -plugs true -scn true $expressionName`;
-
- if ($selObjAttr == $objAttr[0])
- {
- EEdisplayExpression($expressionName);
- }
- }
- }
-
- } // EEexpressionCreated
-
-
- // ================ EEexpressionEdited ================
- //
- // SYNOPSIS
- // An expression has been edited from outside the editor.
- // If it's in the editor, reload it.
- //
- //
- global proc EEexpressionEdited(string $expressionName)
- {
- global int $EEeditedInEditor;
-
- if (!`window -exists "expressionEditorWin"`)
- return;
-
- if ($EEeditedInEditor)
- {
- $EEeditedInEditor = 0;
- return;
- }
-
- // If the expression is in the editor, reload it.
- //
- string $currExprName = `textField -q -tx EEexprNameT`;
-
- if ($expressionName == $currExprName)
- {
- EEdisplayExpression($expressionName);
- }
-
- } // EEexpressionEdited
-
-
- // ================ EEparticleExpressionCreated ================
- //
- // SYNOPSIS
- // Called from TexprEdListenAction.
- // A particle expression has been created from outside the editor.
- // If in "Expression" mode, add it to the node list. If needed,
- // load the new expression.
- //
- //
- global proc EEparticleExpressionCreated(string $which, string $nodeName)
- {
- global string $EEnodeMode;
- global int $EEeditedInEditor;
-
- if (!`window -exists "expressionEditorWin"`)
- return;
-
- if ($EEeditedInEditor)
- {
- $EEeditedInEditor = 0;
- return;
- }
-
- // A particle has just had its first expression created.
- // If in expression mode, add the particle to the node list.
- // If in object mode and the particle is selected, bring in
- // its expression, and put the editor in edit mode.
- //
- if ($EEnodeMode == "expression" && $which == "first")
- {
- EEaddNodeToList($nodeName);
- }
- else
- {
- string $selected[] = `textScrollList -q -si EEnodeList`;
- if ($selected[0] == $nodeName)
- {
- string $particleExpr =
- EEgetParticleExpression($nodeName, "");
-
- if (size($particleExpr) > 0)
- {
- scrollField -e -tx $particleExpr EEmultiText;
- EEsetEditMode("Editing ParticleExpression");
- }
- }
- }
-
- } // EEparticleExpressionCreated
-
-
- // ================ EEparticleExpressionDeleted ================
- //
- // SYNOPSIS
- // A particle expression has been deleted from outside the
- // expression editor. If in "Expression" mode, remove it from
- // the node list. If selected, remove it from the expression
- // textfield and name field.
- //
- //
- global proc EEparticleExpressionDeleted(string $which, string $nodeName)
- {
- global string $EEnodeMode;
- global int $EEisRuntime;
-
- if (!`window -exists "expressionEditorWin"`)
- return;
-
- string $selected[] = `textScrollList -q -si EEnodeList`;
-
- // A particle has just had its last expression deleted.
- // If in expression mode, remove the particle from the node list.
- // If in object mode and the particle is selected, delete the
- // expression, and put the editor in create mode.
- //
- if ($EEnodeMode == "expression" && $which == "all")
- {
- EEremoveNodeFromList($nodeName, 1);
- EEclearAllControls();
- }
- else
- {
- if ($selected[0] == $nodeName)
- {
- if (($which == "creation" && !$EEisRuntime) ||
- ($which == "runtime" && $EEisRuntime) ||
- ($which == "all"))
- {
- EEdisplayNoExpression($nodeName);
- }
- }
- }
-
- } // EEparticleExpressionDeleted
-
-
- // ================ EEparticleExpressionEdited ================
- //
- // SYNOPSIS
- // A particle expression has been edited from outside the
- // editor. If it's in the editor, reload it.
- //
- //
- global proc EEparticleExpressionEdited(string $which, string $nodeName)
- {
- global int $EEisRuntime;
- global int $EEeditedInEditor;
-
- if (!`window -exists "expressionEditorWin"` )
- return;
-
- if ($EEeditedInEditor)
- {
- $EEeditedInEditor = 0;
- return;
- }
-
- // If the expression is in the editor, reload it.
- //
- string $currExprName = `textField -q -tx EEexprNameT`;
-
- if ($nodeName == $currExprName)
- {
- if (($which == "creation" && !$EEisRuntime) ||
- ($which == "runtime" && $EEisRuntime))
- {
- string $expression = EEgetParticleExpression($nodeName, "");
-
- scrollField -e -tx $expression EEmultiText;
- }
- }
-
- } // EEparticleExpressionEdited
-
-
-
- // ================ EEclearExpressionEditor ================
- //
- // SYNOPSIS
- // Clear the editor. This is called when there is a file new or file
- // open, after the old scene has been removed, so we want to clear the
- // editor, but not try to remove client messages. But we do need to
- // clear up FAM connections if the user has left an external test editor
- // up.
- //
- global proc EEclearExpressionEditor()
- {
- global string $EEorigExpressionName;
- global string $EEcurrExpressionName;
- global string $EEcurrSelectedNode;
- global string $EEnodeMode;
-
- global int $EEpExpressionInEditor;
- global int $EEexpressionInEditor;
- global int $EEobjIsParticle;
-
- global string $EEcurrFiles[];
- global string $EEcurrFileExprName[];
- global int $EEcurrFileCreateMode[]; // 1 = creating; 0 = editing
- global string $EEcurrFileDefObj[];
- global string $EEcurrParticleFiles[];
-
- if (!`window -exists "expressionEditorWin"` )
- return;
-
- // If there are editors left up with files from the scene being deleted,
- // delete the expression file to force call to FAM to clean up. This will
- // not take down the editor, but it will at least disconnect it from FAM,
- // since its contents are not longer in the scene. Note too that this
- // will delete the edit file but not the .EXE file. It can't be fully
- // removed because if the editor is up, it is a running process, and FAM
- // doesn't get called. So here delete the expression file through normal
- // channels, which will break its FAM connection and clean up the EE
- // internal structures. When the user does dismiss the external text editor,
- // the .EXE file will get removed and FAM will be called to disconnect it
- // from monitoring.
- //
- if (size($EEcurrFiles) > 0)
- {
- for ($i = 0; $i < size($EEcurrFiles); $i++)
- {
- EEdeleteEditorFile($EEcurrFiles[$i]);
- }
- }
-
- if (size($EEcurrParticleFiles) > 0)
- {
- for ($i = 0; $i < size($EEcurrParticleFiles); $i++)
- {
- EEdeleteEditorFile($EEcurrParticleFiles[$i]);
- }
- }
-
- $EEpExpressionInEditor = -1;
- $EEexpressionInEditor = -1;
-
- // Clear the old object and attribute lists.
- //
- textScrollList -e -ra EEnodeList;
- textScrollList -e -ra EEattrList;
-
- // Clear the expression name, selected object name, default object name
- // textfields.
- //
- textField -e -tx "" EEexprNameT;
- textFieldGrp -e -tx "" EEselNameT;
- textFieldGrp -e -tx "" EEdefNameT;
-
- // Clear the expression scrolled text field.
- //
- scrollField -e -tx "" EEmultiText;
-
- // Reset some buttons.
- //
- checkBox -e -v 1 EEanimCBox;
- radioButtonGrp -e -sl 1 EEunitsRBG;
-
- // Set in create mode.
- //
- if ($EEnodeMode == "scriptNode")
- EEsetCreateMode("Creating Script Node");
- else
- EEsetCreateMode("Creating Expression");
-
- // If in particle expression mode, switch to regular expression mode.
- //
- if ($EEobjIsParticle)
- {
- $EEobjIsParticle = 0;
- EEswitchRulesForm(0);
- text -e -enable true EEexprNameLabel;
- }
-
- $EEcurrSelectedNode = "";
- $EEcurrExpressionName = "";
- $EEorigExpressionName = "";
-
- } // EEclearExpressionEditor
-
-
-
- // ================ EEresetExpressionEditor ================
- //
- // SYNOPSIS
- // Clear the editor. This is called when there is a file new or file
- // open, after the old scene has been removed, so we want to clear the
- // editor, but not try to remove client messages.
- //
- global proc EEresetExpressionEditor()
- {
- global string $EEnodeMode;
-
- // Clear the editor;
- //
- EEclearExpressionEditor();
-
- // Rebuild it if required.
- //
- EErebuildNodeList($EEnodeMode);
-
- } // EEresetExpressionEditor
-